import axios from "@/utils/request.js";

/**
 * 添加训练
 * @param trainForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainAddService = (trainForm) => {
  return axios.post("/trainInfo/add",trainForm)
}

/**
 * 分页查询训练
 * @param currentPage
 * @param pageSize
 * @param trainNameInput
 * @param authorInput
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainSelectService = (currentPage,pageSize,trainNameFuzzy,trainTime,beginTime,endTime) => {
  return axios.get("/trainInfo/loadDataList",{params:{
    currentPage,pageSize,trainNameFuzzy,trainTime,beginTime,endTime
    }})
}

/**
 * 开启/关闭训练
 * @param trainId
 * @param openTrain
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainOpenOrCloseService = (trainId,openTrain) => {
  return axios.put("/train/changeOpenTrain",{trainId,openTrain})
}

/**
 * 根据id删除训练
 * @param trainId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainDeleteService = (trainId) => {
  return axios.delete("/trainInfo/deleteTrainInfoByTrainId",{params:{
    trainId
  }})
}

/**
 * 根据训练id查询题目数组
 * @param titleId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainSelectTitlesByTitleIdService = (trainId) => {
  return axios.get("/train/selectTitlesByTrainId",{params:{trainId: trainId}})
}

/**
 * 根据训练id查询题目id数组和题目名称数组
 * @param trainId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainSelectTitleIdsAndNamesService = (trainId) => {
  return axios.get("/train/selectTitlesArrByTrainId",{params:{trainId: trainId}})
}

/**
 * 修改训练
 * @param trainForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainModifyService = (trainForm) => {
  return axios.put("/trainInfo/updateTrainInfoByTrainId",trainForm)
}

/**
 * 查询所有训练次数 （用于echarts图渲染）
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const trainCountAllService = () => {
  return axios.get("/train/countAll")
}
